package cn.tedu.duotai;

public class DuoTaiDemo {
    public static void main(String[] args) {
//        Dog dog = new Dog();
//        dog.eat();
        //向上造型
//        Pet p = new Dog();//创建Dog的对象赋值给Pet类型的p
//        p.sleep();
//        p.eat();//Dog类重写的eat方法
////        p.jump();//编译报错 Pet中是否包含jump Pet中没有jump方法
//        Pet p1 = new Cat();//创建Cat的对象赋值给Pet类型的p1
//        p1.sleep();
//        p1.eat();//Cat类重写的eat方法
        //编译看左边 运行看右边

        //创建Master对象
//        Cat cat = new Cat();//cat 0x001
//        cat.name = "小白";
//        cat.age = 1;
//        Master m1 = new Master("好老师",cat);
//        System.out.println(m1.name);
//        System.out.println(m1.cat.name+","+m1.pet.age);
//        Dog dog= new Dog();
//        dog.name = "小黑";
//        dog.age = 2;
//        Master m2 =new Master("好老师",dog);
//        System.out.println(m2.name);
//        System.out.println(m2.pet.name+","+m2.pet.age);
//
//        //
//        Bird bird = new Bird();
//        bird.name = "小鸟";
//        bird.age = 3;
//        Master m3 =new Master("好老师",bird);
//        System.out.println(m3.name);
//        System.out.println(m3.pet.name+","+m3.pet.age);

        PetShop shop = new PetShop();
        Dog dog = new Dog();
        dog.name = "小黑";
        shop.sell(dog);
        Cat cat = new Cat();//cat 0x001
        cat.name = "小白";
        shop.sell(cat);
    }
}
